<%--
  Created by IntelliJ IDEA.
  User: 14533
  Date: 2021/10/29
  Time: 14:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/amazeui.min.css" />
    <link rel="stylesheet" href="css/admin.css" />
</head>

<body>
<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">用户管理</strong><small></small></div>
    </div>
    <hr>
    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default btnAdd"><span class="am-icon-plus"></span> 新增</button>
                    <button type="button" style="margin-left: 20px;" class="am-btn am-btn-default btnIn" onclick="sendReq(0)">
                        <span class="am-icon-child"></span> 在职员工
                    </button>
                    <button type="button" style="margin-left: 20px;" class="am-btn am-btn-default btnOut" onclick="sendReq(1)">
                        <span class="am-icon-child"></span> 离职员工
                    </button>
                </div>
            </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">
        </div>
        <div class="am-u-sm-12 am-u-md-3">
            <div class="am-input-group am-input-group-sm" style="margin-right: 30px;">
                <input type="text" id="searchTxt" class="am-form-field" placeholder="请输入用户姓名">
                <span class="am-input-group-btn">
							<button class="am-btn am-btn-default" onclick="findByName(${estatus})">搜索</button>
						</span>
            </div>
        </div>
    </div>
    <div class="am-g">
        <div class="am-u-sm-12">
            <form class="am-form">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th class="table-check"><input type="checkbox" id="chkAll"></th>
                        <th class="table-id" style="width:100px;">ID</th>
                        <th class="table-title">账号</th>
                        <th class="table-type">姓名</th>
                        <th class="table-author am-hide-sm-only">性别</th>
                        <th class="table-author am-hide-sm-only">入职时间</th>
                        <th class="table-dname">离职时间</th>
                        <th class="table-role">职位</th>
                        <th class="table-title">薪水</th>
                        <th class="table-title">状态</th>
                        <th class="table-type">所在部门</th>

                        <th class="table-set">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${employees}" var="emp">
                        <tr>
                            <td><input type="checkbox" name="chk"></td>
                            <td>${emp.eid}</td>
                            <td>${emp.ename}</td>
                            <td>
                                <a href="#">${emp.realname}</a>
                            </td>
                            <td class="am-hide-sm-only">
                                <c:if test="${emp.esex==0}">
                                    <span class="am-badge  am-badge-primary ">男</span>
                                </c:if>
                                <c:if test="${emp.esex==1}">
                                    <span class="am-badge  am-badge-danger ">女</span>
                                </c:if>
                            </td>
                            <td>
                                <c:if test="${emp.entrydate==null}">
                                    ---
                                </c:if>
                                <c:if test="${emp.entrydate!=null}">
                                    <fmt:formatDate value="${emp.entrydate}" pattern="yyyy-MM-dd"/>
                                </c:if>
                            </td>
                            <td>
                                <c:if test="${emp.leavedate==null}">
                                    ---
                                </c:if>
                                <c:if test="${emp.leavedate!=null}">
                                    <fmt:formatDate value="${emp.leavedate}" pattern="yyyy-MM-dd"/>
                                </c:if>
                            </td>
                            <td>
                                <c:if test="${emp.position==0}">
                                    老板
                                </c:if>
                                <c:if test="${emp.position==1}">
                                    经理
                                </c:if>
                                <c:if test="${emp.position==2}">
                                    员工
                                </c:if>
                            </td>
                            <td>${emp.sal}</td>
                            <td>${emp.estatus==0?'在职':'离职'}</td>
                            <td>${emp.dname}</td>

                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <c:if test="${emp.estatus==0}">
                                            <button type="button" onclick="findByEid(${emp.eid})" id="depart_24" class="am-btn am-btn-default am-btn-xs am-text-secondary btnedit">
                                                <span class="am-icon-pencil-square-o"></span> 编辑
                                            </button>
                                            <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger amt-hide-sm-only" onclick="updateEmp(${emp.eid}, 1)">
                                                <span class="am-icon-trash-o"></span> 删除
                                            </button>
                                        </c:if>
                                        <c:if test="${emp.estatus==1}">
                                            <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger amt-hide-sm-only" onclick="updateEmp(${emp.eid}, 0)">
                                                <span class="am-icon-trash-o"></span> 恢复
                                            </button>
                                        </c:if>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </c:forEach>

                    </tbody>
                </table>
                <c:if test="${like!=1}">
                    <div class="am-cf" style="margin-right: 30px;">
                        共 ${lines} 条记录
                        <div class="am-fr">
                            <ul class="am-pagination">

                                <c:if test="${page==1}">
                                    <li class="am-disabled">
                                        <a href="#">«</a>
                                    </li>
                                </c:if>
                                <c:if test="${page>1}">
                                    <li>
                                        <a href="findByPage?estatus=${estatus}&page=${page-1}&size=4">«</a>
                                    </li>
                                </c:if>

                                <c:forEach begin="1" end="${pages}" step="1" var="index">
                                    <c:if test="${page==index}">
                                        <li class="am-active">
                                            <a href="findByPage?estatus=${estatus}&page=${index}&size=4">${index}</a>
                                        </li>
                                    </c:if>
                                    <c:if test="${page!=index}">
                                        <li>
                                            <a href="findByPage?estatus=${estatus}&page=${index}&size=4">${index}</a>
                                        </li>
                                    </c:if>
                                </c:forEach>

                                <c:if test="${page==pages}">
                                    <li class="am-disabled">
                                        <a href="#">»</a>
                                    </li>
                                </c:if>
                                <c:if test="${page<pages}">
                                    <li>
                                        <a href="findByPage?estatus=${estatus}&page=${page+1}&size=4">»</a>
                                    </li>
                                </c:if>
                            </ul>
                        </div>
                    </div>
                </c:if>
                <hr>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript" src="js/jquery-1.11.3.min.js" ></script>
<script type="text/javascript" src="myplugs/js/plugs.js" ></script>
<script>
    $(function() {
        $(".btnAdd").click(function() {
            $.jq_Panel({
                title: "添加员工",
                iframeWidth: 600,
                iframeHeight: 560,
                url: "addUser.html"
            });
        });

    });

    function sendReq(estatus) {
        window.location.href = "findByPage?estatus=" + estatus + "&page=1&size=4";
    }

    function updateEmp(eid, estatus) {
        window.location.href = "updateEmp?estatus=" + estatus + "&eid=" + eid;
    }

    function findByName(estatus) {
        var searchKey = document.getElementById("searchTxt").value;
        window.location.href = "findByName?realname=" + searchKey + "&estatus=" + estatus;
    }

    function findByEid(eid) {
        $.jq_Panel({
            title: "编辑员工",
            iframeWidth: 600,
            iframeHeight: 560,
            url: "findByEid?eid=" + eid
        });
    }

</script>
</body>

</html>
